package com.hongmeng.operater.service.aliyun;

import com.alibaba.fastjson.JSONObject;
import com.hongmeng.common.core.domain.AjaxResult;
import com.hongmeng.common.utils.DateUtils;
import com.hongmeng.operater.annotation.VodCallbackHandlerAnnotation;
import com.hongmeng.operater.domain.aliyun.FileUploadCompleteEntity;
import com.hongmeng.operater.listener.vodHandle.IVodCallbackHandler;


/**
 * 阿里云视频上传后的回调
 */
@VodCallbackHandlerAnnotation(value="FileUploadComplete")
public abstract class FileUploadCompleteListener implements IVodCallbackHandler {

   /**
    * 新增notify方法
    * @param iVodDto
    * @return
    */
   public abstract AjaxResult notify(FileUploadCompleteEntity iVodDto);

   @Override
   public void handelResult(JSONObject jsonObject) {
      FileUploadCompleteEntity vodUploadDto = new FileUploadCompleteEntity();
      vodUploadDto.setStatus(jsonObject.getString("Status"));
      String formate = "yyyy-MM-dd'T'HH:mm:ss'Z'";

      vodUploadDto.setEventTime(DateUtils.StringToDate(jsonObject.getString("EventTime"),formate));
      vodUploadDto.setFileUrl(jsonObject.getString("FileUrl"));
      vodUploadDto.setSize(jsonObject.getLong("Size"));
      vodUploadDto.setVideoId(jsonObject.getString("VideoId"));
      //模板方法调用触发子类实现
      this.notify(vodUploadDto);
   }

}
